For elements in group 2, their valence electrons consist of "ns2" where n is the principle quantum number/shell number. However, for elements in group 3, their valence electrons consist of "ns2np1". As the p-orbitals are higher in energy than the s-orbitals, this makes the p electron easier to remove and hence required less energy input - resulting a slightly lower 1st ionisation energy than expected. For elements in group 5, they all have singly filled p-orbitals ("np3), but those in group 6 have one p-orbital with a pair of electrons occupying it ("np4"). This is known as an orbital pair with anti-spin. The pairing of electrons within an orbital causes repulsion between those occupying it - this highers the electrons energy. As their energy is now higher, it is easier to remove the electron as a result, which lowers the 1st ionisation energy.