How to get iMessages to sync across an iPhone, iPad and Mac automatically?
iOS (6 and later) combines your phone number with your Apple ID email address, which makes it possible for others to iMessage your phone number and have those Messages sync across your devices.

First, you need to make sure all your devices are on the same Apple ID.

On each iOS device (iPhone, iPod Touch, iPad, iPad Mini):


Open Settings.app
Go to "Messages" and make sure iMessage is On. 
If iMessage is on, "Send &amp; Receive" will appear below it. Tap on it.
Make note of the Apple ID at the top of the page.
Select your phone number and email address(es) that you want to sync to that device.


On each Mac: (Mountain Lion or later)


Open Messages
Click Messages -> Preferences
Click the "Accounts" tab in the top.
Select your iMessage/Apple ID account, and make sure "Enable this account" is checked.
Select your phone number and any email address(es) that you would like synced.


The most important part is that everything is consistent across all devices that are necessary. 



Message History

The steps described previously will not automatically cause old iMessages to sync across all devices. However, iOS and macOS now support "Messages in iCloud": Apple Support Document. Enabling Messages in iCloud will sync historical messages across all of your devices. Make sure you are running the latest version of macOS or iOS.

To turn on Messages in iCloud on your iOS device:


Open Settings app.
Tap your Apple ID profile at the top of the list.
Select iCloud.
Enable Messages. 


To enable on your Mac:


Open the Messages app.
In the menu bar, select Messages -> Preferences.
Open the iMessage tab.
Select the checkbox to Enable Messages in iCloud.




Additional Troubleshooting steps

If you are still having trouble getting new iMessages to sync across the devices try:


Disabling then re-enabling iMessage on each device that isn't being synced to.
Delete all your previous conversations: Some people have reported that they had to delete all of their conversations before things would sync up.
Make sure you have your phone number added to your Apple ID account online.