What type of fence do you have? If it is a timber fence I believe the easiest option would be to screw a four Zenith 90 x 6mm Stainless Steel Ceiling Screw Hooks into the top horizontal timber beam of the fence. The top rear board of the pallet could be placed over the hooks to hold the pallet in place. Before placing the pallet on the fence you might like to drive some additional screws through the top board and into the frame of the pallet. This will ensure the board is not pulled off from the additional weight of the garden.
Alternatively, you could screw through the rear boards of the pallet directly into the fence.