Now first of all according to the tafsir books this Verse was revealed with his predecessors so you should read them together!
According to tafsir att-tahrir wa at-Tanwir التحرير والتنوير a group of man (sahaba) wanted to refraining from all lusts of dunya to get near the Messenger of Allah (peace be upon him) in rank.
According to the Imams at-Tabari and al-Wahidi the narration (in Arabic) was reveled because of this story:
روى الطبري والواحدي أن نفرا تنافسوا في الزهد . فقال أحدهم : أما أنا
فأقوم الليل لا أنام ، وقال الآخر : أما أنا فأصوم النهار ، وقال الآخر :
أما أنا فلا آتي النساء ، فبلغ خبرهم رسول الله صلى الله عليه وسلم فبعث
إليهم ، فقال : ألم أنبأ أنكم قلتم كذا ؟ قالوا : بلى يا رسول الله ، وما
أردنا إلا الخير ، قال : لكني أقوم وأنام وأصوم وأفطر ، وآتي النساء ،
فمن رغب عن سنتي فليس مني فنزلت هذه الآية
(My own translation so be careful)
A group of people compete in asceticism. One of them said: as for me.
i shall offer Salat (prayer) all night long and don't sleep, and an
other one said: as for me. i shall observe Saum (fasting) during the
day. And the other said: I shall abstain from women and shall have a
woman (wife). News of that reached the Messenger of Allah and he
praised Allah then said: "I have been told that you said such and such
things?, they answered: Yes o Messenger of Allah, but we only wanted
to do good (deeds). He said: But I stand (in prayer) and sleep, I fast
and I break my fast, and I marry women. Whoever turns away from my
Sunnah is not of me."
You may find in the Sahih books and some Sunan books a Narration which is similar but they don't claim this to be the reason for revealing those Verses!
Here's a link to the Version from Sahih al-Bukahri and a link to the Version of Sunan an-Nasa-i.
In some Narration those who decided to refrain from all(or almost) lusts of dunya where Abu Bakr أبو بكر, Ali علي, ibn Masu'd ابن مسعود, ibn O'mar ابن عمر, abu Dhar أبو ذر, Salim mawla abi Hudaifa سالم مولى أبي حذيفة, al-Miqdad ibn al-Aswad المقداد بن الأسود, Salman al-Farisi سلمان الفارسي and Mi'qal ibn Moqrin (i hope i didn't transliterate it wrong) معقل بن مقرن and they met at the house of 'Othman ibn Madhu'n عثمان بن مظعون. But this would mean that this happened at the early days of hijra as 'Othman didn't have a house in Medina and died in 2a.H. On the other hand in Sunan Abi Dawod there's a Hadith in which the speech is directed to 'Othman, which seems to support this story!
A third story says that some Sahaba wanted to do like Christians and interdicted to themselves some kind of meat, some of their (nap or length of the sleep) sleep, some of their physical acts with their wife's and they made oaths to oblige themselves!
I think about the oaths you can use the comment of @servant-of-Wiser
But if you still have questions feel free to ask!
And Allah knows best!