First of all, Android M developer preview will not be available for any random device. It is available only for certain devices.
Here is the guide on how to do it, but be aware that this preview is meant for developers and it needs you to have sound knowledge of the tools involved, else you are likely to run the risk of bricking your phone.
1. Make sure your device is unlocked. There is no need to root.
2. Have ADB and fastboot installed on your computer. You can download the installer from the link http://forum.xda-developers.com/showthread.php?t=2317790
3. Download the factory image of your device from the link http://developer.android.com/preview/download.html
Make sure you have selected the correct build of your device.
4. Unzip this file and save it at some location on your computer.
5. Connect your device to the PC via USB. Make sure "USB DEBUGGING " option is on.
6. Open ADB command. Type adb reboot bootloader which will access your device bootloader.
7. Find out the image file you saved in step 4.
8. Type in flash-all to run installation.
Your device will take a bit longer to reboot. Do not panic and wait patiently. Once the device boots up, enjoy the Android M preview.
Note - The procedure will wipe out all data fro your device. Be sure to back up all your data.
Live....and Let Live!