Strongly magnetic atoms offer unique possibilities to study many-body quantum phenomena with anisotropic interactions. Here we present the first study on the superfluid-to-Mott insulator transition with dipolar erbium atoms and evidence of the nearest-neighbour interaction (NNI) between the atoms. A BEC of 168Er atoms is prepared in a three-dimensional optical lattice with rectangular unit cell, created by two retro-reflected beams at 532 nm and a 1064nm beam in the vertical axis. The system behaviour is well described with an extended Bose-Hubbard model, which includes the onsite dipole-dipole interaction (DDI) and the NNI. In the Mott-insulating state, we measure the onsite interaction energy originating from DDI via modulation spectroscopy. As a function of the onsite trap aspect ratio (AR) and the dipole orientation we can tune the onsite DDI from repulsive to attractive values in excellent agreement to theoretical predictions. A closer look on the superfluid-to-Mott insulator transition reveals a shift of the critical point depending on the dipole orientation. Comparing to theoretical calculations, we see indications of important anisotropic modifications to the tunnelling rates caused by DDI. Finally, using a differential probing technique, we are able to directly measure the NNI in very good agreement with the theoretical value.