What inspired Maxwell's four equations?

The experimental and theoretical work of Faraday, who was not mathematically inclined, but still a gifted self taught physicist. Maxwell essentially put into equations the ideas of Faraday and Oerster/Ampere . Faraday had the idea of directed fields and lines of force. The only mathematics to describe these ideas was William Rowan Hamilton's Quaternions and especially the vector part of quaternions. Vectors described the directied forces and lines.

Maxwell found out about quaternions and vectors and thus his four equations involve vectors. Maxwell, ignored the scalar part of quaternions and he did not like the quaternions rules for vectors which gave the product of parallel vectors a negative sign.

Oliver Heaviside and Willard Gibbs, changed Hamilton's Rule and defined their "Vector Analysis" to have a positive sign. This is the rule currently used in physics today. Unfortunately, this rule makes Gibbs vectors non-associative (II)J = J but I(IJ) = -J. Hamilton's Quaternions define and Division Algebra.