Higher octanes are designed to prevent preignition of the fuel in engines that are supercharged/turbocharged or use higher compression ratios. Preignition is when the fuel combusts before the cylinder is at the "ready" point in its cycle (wherever that is for your car, with variable timing and all that).
As others have said, your manual will tell you, but a good rule of thumb is if you don't have a high performance vehicle or an engine with a turbo or supercharger, 87 should be fine.