Usually, when you add a new partition to a Mac using Disk Utility, you can then just (minus sign) delete the new partition and Disk Utility will automatically expand your first partition to take up the free space.
Occasionally, Macs will act weird and not fill up the free space and, more importantly, not let you manually drag the old partition to fill up the free space. You’re just stuck with unusable free space.
There is a relatively simple solution that involves only a couple of terminal commands. (Thanks to the Restore Macintosh HD to its original partition configuration thread on Stack Exchange for the tip.)
Boot up into recovery mode (Cmd-R at startup). If you want to be extra safe, use Disk Utility to back up your first partition in case something goes wrong.
Go to Utilities > Terminal.
Enter in this command:
That’s it. Your partition should now be fully expanded.