I did some analysis of the chorale 'Wie wunderbarlich ist doch diese Strafe' (from Matthew Passion BWV 244 no.46), see below. But how would I analyse the first chord in measure 2? Obviously, it's an E major chord (1st inversion), but what is its function? You could say it's an altered subdominant, IV♯3, but I think such things are very rare in Bach's music. It could be a secondary dominant, but the following chord is F♯65, of which E major is neither the V nor the VII. So, any help?

[![enter image description here](https://i.stack.imgur.com/PK4W6.png)](https://i.stack.imgur.com/PK4W6.png)