Long-term multiwavelength view of the blazar 1ES 1218+304