These ahadith that have been narrated to state that Hadith should not be written is mostly attributed to
Umar the second khalif and not to the prophet himself. In fact the prophet encouraged the writing of his saying. And Allah said in the Quran:
Holy Quran 59:7
——————
مَّا أَفَاءَ اللَّهُ عَلَىٰ رَسُولِهِ مِنْ أَهْلِ الْقُرَىٰ فَلِلَّهِ وَلِلرَّسُولِ وَلِذِي الْقُرْبَىٰ وَالْيَتَامَىٰ وَالْمَسَاكِينِ وَابْنِ السَّبِيلِ كَيْ لَا يَكُونَ دُولَةً بَيْنَ الْأَغْنِيَاءِ مِنكُمْ ۚ وَمَا آتَاكُمُ الرَّسُولُ فَخُذُوهُ وَمَا نَهَاكُمْ عَنْهُ فَانتَهُوا ۚ وَاتَّقُوا اللَّهَ ۖ إِنَّ اللَّهَ شَدِيدُ
الْعِقَابِ
And whatever the Messenger has given you – take; and what he has forbidden you – refrain from. And fear Allah; indeed, Allah is severe in penalty.
Therefore Hadith is important to understand the Quran and to understand the Quran you need authentic narrations that are narrated and verified through Ahlulbait.